<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
    </script>
<body>
<table class="table">
    <thead>
    <tr>
        <th>ID</th>
        <th>用户名</th>
        <th>密码</th>
        <th>手机号</th>
        <th>性别</th>
        <th>爱好</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {foreach getUserAll as $v}
    <tr>
        <td>{$v.id}</td>
        <td>{$v.username}</td>
        <td>{$v.password}</td>
        <td>{$v.tel}</td>
        <td>{$v.age}</td>
        <td>{$v.hobby}</td>
        <td>
            {if ($v.state==1)}
            <span class="state{$v.id}"  states="2">正常</span>
            {elseif($v.state==2)}
            <span class="state{$v.id}"  states="1">冻结</span>
            {else}
            <span class="state{$v.id}"  states="1">未审核</span>
            {/if}
            </td>
        <td>
            <button onclick="next0({$v.id})">通过</button>
            <button onclick="next1({$v.id})">不通过</button>
            <button onclick="next2({$v.id})">冻结</button>
        </td>
    </tr>
    {/foreach}
    </tbody>
</table>
</body>
</html>
<script>
    function next2(id) {
        var state=$(".state"+id).attr('states');
        $.ajax({
            url:'audit',
            type:'GET',
            data:{
                id:id,
                state:state
            },
            dataType:'JSON',
            success:function (e) {
                console.log(e)
                if (e.data.state==2){
                    $(".state"+id).text('冻结');
                    $(".state"+id).attr('state',1);
                }
            }
        })
    }
    function next0(id) {
        var state=$(".state"+id).attr('states');
        $.ajax({
            url:'audit',
            type:'GET',
            data:{
                id:id,
                state:state
            },
            dataType:'JSON',
            success:function (e) {
                console.log(e)
                if (e.data.state==1){
                    $(".state"+id).text('正常');
                    $(".state"+id).attr('state',2);
                }
            }
        })
    }
</script>